<?php


namespace App\Http\Controllers\admin\validate;


use Illuminate\Support\Facades\Validator;

class File
{
    public static function addFile($param){
        $rules = [
            'userId'=>'required|numeric',
            'lastIp'=>'required|ip',
            'type'=>'required',
            'file'=>'required'
        ];
        $msg = [
            'userId.required'=>'用户编号为空',
            'userId.numeric'=>'用户编号格式不对',
            'lastIp.required'=>'IP地址为空',
            'lastIp.ip'=>'IP地址格式不对',
            'type.required'=>'类型为空',
            'file.required'=>'文件为空'
        ];
        return Validator::make($param,$rules,$msg)->errors()->all();
    }

    public static function queryFile($param){
        $rules = [
            'startSize'=>'required|numeric',
            'pageSize'=>'required|numeric'
        ];
        $msg = [
            'startSize.required'=>'当期页为空',
            'startSize.numeric'=>'当期页格式不对',
            'pageSize.required'=>'页面显示数为空',
            'pageSize.numeric'=>'页面显示数格式不对'
        ];
        return Validator::make($param,$rules,$msg)->errors()->all();
    }

    public static function queryIdFile($param){
        $rules = [
            'id'=>'required|numeric',
        ];
        $msg = [
            'id.required'=>'编号为空',
            'id.numeric'=>'编号格式不对'
        ];
        return Validator::make($param,$rules,$msg)->errors()->all();
    }

    public static function editFile($param){
        $rules = [
            'userId'=>'required|numeric',
            'lastIp'=>'required|ip',
            'id'=>'required|numeric',
            'type'=>'required',
            'file'=>'required'
        ];
        $msg = [
            'userId.required'=>'用户编号为空',
            'userId.numeric'=>'用户编号格式不对',
            'lastIp.required'=>'IP地址为空',
            'lastIp.ip'=>'IP地址格式不对',
            'id.required'=>'编号为空',
            'id.numeric'=>'编号格式不对',
            'type.required'=>'类型为空',
            'file.required'=>'文件为空',
        ];
        return Validator::make($param,$rules,$msg)->errors()->all();
    }

    public static function deleteFile($param){
        $rules = [
            'userId'=>'required|numeric',
            'lastIp'=>'required|ip',
            'id'=>'required|numeric',

        ];
        $msg = [
            'userId.required'=>'用户编号为空',
            'userId.numeric'=>'用户编号格式不对',
            'lastIp.required'=>'IP地址为空',
            'lastIp.ip'=>'IP地址格式不对',
            'id.required'=>'编号为空',
            'id.numeric'=>'编号格式不对'
        ];
        return Validator::make($param,$rules,$msg)->errors()->all();
    }

    public static function uploadFile($param){
        $rules = [
            'userId'=>'required|numeric',
            'lastIp'=>'required|ip',
            'file'=>'required',

        ];
        $msg = [
            'userId.required'=>'用户编号为空',
            'userId.numeric'=>'用户编号格式不对',
            'lastIp.required'=>'IP地址为空',
            'lastIp.ip'=>'IP地址格式不对',
            'file.required'=>'文件为空',
        ];
        return Validator::make($param,$rules,$msg)->errors()->all();
    }

    public static function getFileType($param){
        $rules = [
            'userId'=>'required|numeric',


        ];
        $msg = [
            'userId.required'=>'用户编号为空',
            'userId.numeric'=>'用户编号格式不对',

        ];
        return Validator::make($param,$rules,$msg)->errors()->all();
    }

}